// 84.柱状图中最大的矩形
package Leetcode_Second_Brush;

public class Solution084 {
    public int largestRectangleArea(int[] heights) {
        int maxArea = 0;
        for (int i = 0; i < heights.length; i++) {
            int width = 0;
            for (int j = i; j >= 0; j--) {
                if (heights[j] >= heights[i])
                    width++;
                else
                    break;
            }
            for (int j = i + 1; j < heights.length; j++) {
                if (heights[j] >= heights[i])
                    width++;
                else
                    break;
            }
            if (width * heights[i] > maxArea)
                maxArea = width * heights[i];
        }

        return maxArea;
    }

}
